package cn.fxzhang.leetcode.contest.week236;

import java.util.ArrayList;
import java.util.List;

public class P5727_Find_The_Winner_Of_The_Circular_Game {

    public int findTheWinner(int n, int k) {
        List<Integer> list = new ArrayList<>();
        for (int i=1; i<=n; i++){
            list.add(i);
        }
        // 当前位置
        int x = 0;
        // 移除n-1人
        for (int i=0; i<n-1; i++){
            x = (x+k-1)%list.size();
            list.remove(x);
        }
        return list.get(0);
    }
}
